package com.huawei.appgallery.purchasehistory.ui.fragment;

import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.f;
import androidx.recyclerview.widget.RecyclerView.j;
import androidx.recyclerview.widget.RecyclerView.q;
import androidx.recyclerview.widget.RecyclerView.t;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.widget.FilterDataLayout;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.foundation.ui.framework.uikit.ContractFragment;
import com.huawei.appgallery.purchasehistory.api.AppTracesListFragmentProtocol;
import com.huawei.appgallery.purchasehistory.api.bean.FamilyMemberResponseBean.FamilyMemberResponseInfo;
import com.huawei.appgallery.purchasehistory.ui.activity.PurchaseMenuActivity;
import com.huawei.appmarket.framework.widget.ExpandScrollLayout;
import com.huawei.appmarket.framework.widget.SimpleExpandScrollLayout;
import com.huawei.appmarket.support.widget.tabhost.FragmentTabHost;
import com.huawei.secure.android.common.intent.SafeBundle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import o.azb;
import o.cfv;
import o.chj;
import o.cid;
import o.cis;
import o.ciu;
import o.ciw;
import o.ciy;
import o.ciz;
import o.csp;
import o.cst;
import o.cst.d;
import o.csv;
import o.cte;
import o.ctk;
import o.ctp;
import o.dgp;
import o.dky.c;
import o.dky.h;
import o.dky.i;
import o.dof;
import o.ContentManager;
import o.CollectCheck;
import o.MinimumFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class PurchaseHorizontalMultiTabsFragment extends AppListFragment<AppTracesListFragmentProtocol> implements cis, ctk, ctp {
    private ciu ʹ;
    private FragmentTabHost ˊ;
    private int ॱॱ;
    private cte ᐝ;
    private RecyclerView ﹳ;

    static class e extends f {
        private boolean ˊ;

        private e() {
            this.ˊ = MinimumFactory.getBoolValue(ContentManager.getInstant().getContext());
        }

        public void ˏ(@NonNull Rect rect, @NonNull View view, @NonNull RecyclerView recyclerView, @NonNull t tVar) {
            if (recyclerView.ˋ() != null && recyclerView.ʼ(view) != recyclerView.ˋ().ˏ() - 1) {
                int dimension = (int) recyclerView.getResources().getDimension(c.ᐝ);
                if (this.ˊ) {
                    rect.left = dimension;
                } else {
                    rect.right = dimension;
                }
            }
        }
    }

    public void ˏ(Bundle bundle) {
        ॱˋ(true);
        ॱˉ();
        super.ˏ(bundle);
    }

    public void ॱˊ(@Nullable Bundle bundle) {
        super.ॱˊ(bundle);
        if (bundle != null) {
            this.ॱॱ = new SafeBundle(bundle).getInt("SelectedTabPositionKey");
            ͺ(this.ॱॱ);
        }
    }

    public void ˋ(@NotNull Bundle bundle) {
        super.ˋ(bundle);
        if (this.ˊ != null) {
            new SafeBundle(bundle).putInt("SelectedTabPositionKey", this.ˊ.getCurrentTab());
        }
    }

    public int ߵ() {
        return d.ͺ;
    }

    public void ᐝ() {
        super.ᐝ();
        this.ˊ = null;
        this.ᐝ = null;
    }

    public void ॱ(int i, int i2, @Nullable Intent intent) {
    }

    public void ᐨॱ() {
    }

    public void ˏ(@Nullable BaseDetailResponse baseDetailResponse) {
    }

    @Nullable
    public b ʽʻ() {
        return null;
    }

    public void ʽॱ(int i) {
        if (this.ˊ != null && (this.ˊ.ॱ() instanceof cid)) {
            cid o_cid = (cid) this.ˊ.ॱ();
            if (o_cid.ʽʼ() != i) {
                o_cid.ॱᐝ(i);
            }
        }
    }

    public boolean ʻʼ() {
        if (this.ˊ == null || !(this.ˊ.ॱ() instanceof ciz)) {
            return false;
        }
        return ((ciz) this.ˊ.ॱ()).ad_();
    }

    public boolean ad_() {
        return ʻʼ();
    }

    public void ᵔ() {
        this.ߵ = (FrameLayout) this.ॱˍ.findViewById(o.cst.e.ˋˊ);
        ˋ(this.ߵ);
        ˎ(this.ߵ);
        this.ﹳ = (RecyclerView) this.ॱˍ.findViewById(h.ߺ);
        azb.ˏ(this.ﹳ);
        if (this.ʹ == null) {
            this.ʹ = new ciu();
            this.ʹ.ˎ(this);
        }
        this.ﹳ.setAdapter(this.ʹ);
        j linearLayoutManager = new LinearLayoutManager(ॱˋ());
        linearLayoutManager.ˊ(0);
        this.ﹳ.setLayoutManager(linearLayoutManager);
        this.ﹳ.ˋ(new e(), -1);
        ߺ();
        this.ॱʾ = (ExpandScrollLayout) this.ॱˍ.findViewById(h.ᐝˋ);
        this.ߺ = (FilterDataLayout) this.ॱˍ.findViewById(h.ˎˏ);
        this.ॱʾ.setHeadView(this.ߺ);
        this.ॱʾ.setOnScrollListener(new chj(this));
        if (this.ॱʾ instanceof SimpleExpandScrollLayout) {
            ((SimpleExpandScrollLayout) this.ॱʾ).setContentView(this.ˊ);
        }
    }

    private void ˎ(ViewGroup viewGroup) {
        this.ˊ = (FragmentTabHost) viewGroup.findViewById(16908306);
        if (this.ˊ != null) {
            this.ˊ.setup(ॱˊ(), ʽॱ(), 16908305);
            this.ᐝ = new cte(this.ᐝʽ);
            this.ᐝ.ˏ(this.ᵔ);
            this.ˊ.setAdapter(this.ᐝ);
            return;
        }
        csp.ˏ.ˊ("PurchaseHorizontalMultiTabsFragment", "fragmentTabHost == null");
    }

    private void ˋ(@NotNull ViewGroup viewGroup) {
        this.ᴵ.inflate(i.ॱˎ, viewGroup);
    }

    public void ʹॱ() {
    }

    public void ˊ(@Nullable cfv o_cfv) {
    }

    public void ʼ(int i) {
        if (this.ˊ != null) {
            this.ˊ.setCurrentTab(i);
        }
        ˊॱ(i);
        FragmentActivity ॱˋ = ॱˋ();
        Fragment ॱـ = ॱـ();
        if ((ॱˋ instanceof PurchaseMenuActivity) && (ॱـ instanceof ContractFragment)) {
            ((PurchaseMenuActivity) ॱˋ).ˋ((ContractFragment) ॱـ);
        } else {
            csp.ˏ.ˋ("PurchaseHorizontalMultiTabsFragment", "no need changeFragmentMenuStatus");
        }
    }

    public void ॱॱ(int i) {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof ciy) {
            ((ciy) ॱـ).ʾॱ();
        }
    }

    public void ॱˋ(int i) {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof ciy) {
            ((ciy) ॱـ).ˋ(i);
        }
    }

    public void ꞌॱ() {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof ciy) {
            ((ciy) ॱـ).ʽˊ();
        }
    }

    public void ʾॱ() {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof ciy) {
            ((ciy) ॱـ).ʾॱ();
        }
    }

    private void ߺ() {
        this.ʹ.ˋ(new ArrayList(this.ᐝʽ));
        this.ʹ.ʽ(this.ॱॱ);
        this.ʹ.ˊ();
    }

    private void ͺ(int i) {
        if (this.ᐝ != null) {
            this.ᐝ.ˊ();
        }
        if (this.ˊ != null) {
            this.ˊ.setCurrentTab(i);
        }
        if (this.ʹ != null) {
            this.ʹ.ʽ(i);
            this.ʹ.ˊ();
            ˊॱ(this.ʹ.ॱ());
        }
    }

    private void ˊॱ(int i) {
        Context ॱˊ = ॱˊ();
        if (ॱˊ != null && this.ﹳ != null) {
            j ʻ = this.ﹳ.ʻ();
            if (ʻ != null) {
                q o_ciw = new ciw(ॱˊ);
                o_ciw.ॱ(i);
                ʻ.ॱ(o_ciw);
            }
        }
    }

    public void ˋ(int i) {
        super.ˋ(i);
        if (this.ᐝ != null) {
            this.ᐝ.ˏ(true);
        }
    }

    public void ʽˊ() {
        super.ʽˊ();
        if (this.ᐝ != null) {
            this.ᐝ.ˏ(false);
        }
    }

    private Fragment ॱـ() {
        if (this.ˊ == null) {
            return null;
        }
        return this.ˊ.ॱ();
    }

    private boolean ॱˌ() {
        List<FamilyMemberResponseInfo> ˊ = csv.ˋ().ˊ();
        if (CollectCheck.isEmpty((List) ˊ)) {
            csp.ˏ.ˋ("PurchaseHorizontalMultiTabsFragment", "can not get family members.");
            return false;
        }
        String userId = UserSession.getInstance().getUserId();
        for (FamilyMemberResponseInfo familyMemberResponseInfo : ˊ) {
            if (familyMemberResponseInfo.ॱ() == 1 && !dof.ˎ(userId, familyMemberResponseInfo.ˋ())) {
                return true;
            }
        }
        return false;
    }

    private void ॱˉ() {
        Collection arrayList = new ArrayList();
        dgp o_dgp = new dgp();
        o_dgp.ˎ(ॱ(cst.h.ˈ));
        o_dgp.ˋ("apptraceallmultilist.fragment");
        arrayList.add(o_dgp);
        o_dgp = new dgp();
        o_dgp.ˎ(ॱ(cst.h.ʿ));
        o_dgp.ˋ("apptraceuninstallmultilist.fragment");
        arrayList.add(o_dgp);
        if (ॱˌ()) {
            o_dgp = new dgp();
            o_dgp.ˎ(ॱ(cst.h.ʼ));
            o_dgp.ˋ("familysharemember.fragment");
            arrayList.add(o_dgp);
        }
        this.ᐝʽ.addAll(arrayList);
    }

    public void ʽ(int i) {
    }

    public boolean י() {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof ctk) {
            return ((ctk) ॱـ).י();
        }
        return false;
    }

    public void ˊʻ() {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof ctp) {
            ((ctp) ॱـ).ˊʻ();
        } else {
            csp.ˏ.ˏ("PurchaseHorizontalMultiTabsFragment", "fragment not instance of PurchaseJumper, goDeletePage failed");
        }
    }

    public void ٴ() {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof ctp) {
            ((ctp) ॱـ).ٴ();
        } else {
            csp.ˏ.ˏ("PurchaseHorizontalMultiTabsFragment", "fragment not instance of PurchaseJumper, goDeletePage failed");
        }
    }

    public void ॱʾ() {
        Fragment ॱـ = ॱـ();
        if (ॱـ instanceof PurchaseHistoryFragment) {
            ((PurchaseHistoryFragment) ॱـ).ʿˊ();
        }
    }
}
